package com.wc.alorithm_luogu.P1228;


import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;

/**
 * @Author congege
 * @Description 地毯填补问题
 * https://www.luogu.com.cn/problem/P1228
 * @Date Created in 2023/9/16-9:17
 */
public class Main {
    static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        Main main = new Main();
        int bound = (int) Math.pow(2, k);
        main.targetPaint(1, bound, 1, bound, x, y);
        pr.flush();
        scan.close();
    }

    /**
     * 为地毯涂色
     *
     * @param up    上边界
     * @param down  下边界
     * @param left  左边界
     * @param right 有边界
     * @param x     被占位置x坐标
     * @param y     被占位置y坐标
     * @return 顺序
     */
    public void targetPaint(int up, int down, int left, int right, int x, int y) {
//        if (up == down) {
//            return "";
//        }
//        StringBuffer ans = new StringBuffer();
        int midX = (up + down) / 2;
        int midY = (left + right) / 2;

        int insertX;
        int insertY;
        int insertC;


        int[][] map = new int[4][2];

        /**
         * 表示每一个象限对于中间的顶角
         */
        map[0][0] = midX;
        map[0][1] = midY;
        map[1][0] = midX;
        map[1][1] = midY + 1;
        map[2][0] = midX + 1;
        map[2][1] = midY;
        map[3][0] = midX + 1;
        map[3][1] = midY + 1;
        /**
         * 如果在第二象限
         */
        if (x <= midX && y <= midY) {
            insertX = midX + 1;
            insertY = midY + 1;
            insertC = 1;

            map[0][0] = x;
            map[0][1] = y;

        } else if (x <= midX) {
            insertX = midX + 1;
            insertY = midY;
            insertC = 2;


            map[1][0] = x;
            map[1][1] = y;

        } else if (y <= midY) {
            insertX = midX;
            insertY = midY + 1;
            insertC = 3;
            map[2][0] = x;
            map[2][1] = y;
        } else {
            insertX = midX;
            insertY = midY;
            insertC = 4;

            map[3][0] = x;
            map[3][1] = y;
        }
//        pr.printf("%d %d %d\n", insertX, insertY, insertC);
//        ans.append(insertX);
        pr.print(insertX);
//        ans.append(' ');
        pr.print(' ');
//        ans.append(insertY);
        pr.print(insertY);
//        ans.append(' ');
        pr.print(' ');
//        ans.append(insertC);
        pr.print(insertC);
//        ans.append('\n');
        pr.print('\n');
        if (up != midX) {
//            ans.append(targetPaint(up, midX, left, midY, map[0][0], map[0][1]));
            targetPaint(up, midX, left, midY, map[0][0], map[0][1]);
//            ans.append(targetPaint(up, midX, midY + 1, right, map[1][0], map[1][1]));
            targetPaint(up, midX, midY + 1, right, map[1][0], map[1][1]);
        }
        if (midX + 1 != down) {
//            ans.append(targetPaint(midX + 1, down, left, midY, map[2][0], map[2][1]));
            targetPaint(midX + 1, down, left, midY, map[2][0], map[2][1]);
            targetPaint(midX + 1, down, midY + 1, right, map[3][0], map[3][1]);
//            ans.append(targetPaint(midX + 1, down, midY + 1, right, map[3][0], map[3][1]));
        }
//        targetPaint(up, midX, left, midY, map[0][0], map[0][1]);
//        targetPaint(up, midX, midY + 1, right, map[1][0], map[1][1]);
//        targetPaint(midX + 1, down, left, midY, map[2][0], map[2][1]);
//        targetPaint(midX + 1, down, midY + 1, right, map[3][0], map[3][1]);
//        return ans.toString();
        return;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}